import junit.framework.TestCase;


public class DataTest extends TestCase {
	public void testNull() {
		Null n = new Null();
		assertTrue(n.isAtom() == true);
		assertTrue(n.isList() == true);
		assertTrue(n.isNull() == true);
		assertTrue(n.isPair() == false);
		assertTrue(n.toString().equals("()"));
	}

	public void testAtom() {
		Atom a = new Atom(null);
		assertTrue(a.isAtom() == true);
		assertTrue(a.isList() == true);
		assertTrue(a.isNull() == true);
		assertTrue(a.isPair() == false);
		assertTrue(a.toString().equals("()"));

		Atom b = new Atom("b");
		assertTrue(b.isAtom() == true);
		assertTrue(b.isList() == false);
		assertTrue(b.isNull() == false);
		assertTrue(b.isPair() == false);
		assertTrue(b.toString().equals("b"));
		
		Atom c = new Atom(new Integer(3));
		assertTrue(c.isAtom() == true);
		assertTrue(c.isList() == false);
		assertTrue(c.isNull() == false);
		assertTrue(c.isPair() == false);
		assertTrue(c.toString().equals("3"));
	}
	
	public void testPair() {
		Atom a = new Atom(null);

		Atom b = new Atom("b");
		
		Atom c = new Atom(new Integer(3));
		
		Pair z = new Pair(a, b);
		assertTrue(z.isAtom() == false);
		assertTrue(z.isList() == false);
		assertTrue(z.isNull() == false);
		assertTrue(z.isPair() == true);
		assertTrue(z.toString().equals("(() . b)"));
		
		Pair y = new Pair(b, c);
		assertTrue(y.isAtom() == false);
		assertTrue(y.isList() == false);
		assertTrue(y.isNull() == false);
		assertTrue(y.isPair() == true);
		assertTrue(y.toString().equals("(b . 3)"));
		
		Pair x = new Pair(c, a);
		assertTrue(x.isAtom() == false);
		assertTrue(x.isList() == true);
		assertTrue(x.isNull() == false);
		assertTrue(x.isPair() == true);
		System.out.println(x);
		assertTrue(x.toString().equals("(3)")); // Change
	}
	
	public void testData() {
		Data a = new Atom("A");
		Data two = new Atom(new Integer(2));
		Data word = new Atom("word");
		Data n = new Null();
		
		Data p = new Pair(a, two);
		Data l = new Pair(word, n);
		Data l2 = new Pair(a, new Pair(two, l));

		assertTrue(p.isAtom() == false);
		assertTrue(p.isList() == false);
		assertTrue(p.isNull() == false);
		assertTrue(p.isPair() == true);
		assertTrue(p.toString().equals("(A . 2)"));
		
		assertTrue(l.isAtom() == false);
		assertTrue(l.isList() == true);
		assertTrue(l.isNull() == false);
		assertTrue(l.isPair() == true);
		assertTrue(l.toString().equals("(word)")); // Change

		assertTrue(l2.isAtom() == false);
		assertTrue(l2.isList() == true);
		assertTrue(l2.isNull() == false);
		assertTrue(l2.isPair() == true);
		System.out.println(l2);
		assertTrue(l2.toString().equals("(A 2 word)")); // Change
	}
}
